package com.example.adminbase.shiro;

import org.apache.shiro.web.filter.authc.UserFilter;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletResponse;

/**
 * 允许登录用户访问，匿名用户返回401状态码
 */
public class UserExtFilter extends UserFilter {
    @Override
    protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception {
        WebUtil.responseUnauthorized((HttpServletResponse) response);
        return false;
    }
}
